package crmdna.common;

import com.google.appengine.api.NamespaceManager;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

import crmdna.attendance.CheckInEntity;
import crmdna.client.ClientEntity;
import crmdna.client.CrmDnaUserEntity;
import crmdna.client.CustomFieldsEntity;
import crmdna.client.isha.IshaConfigEntity;
import crmdna.common.config.ConfigCRMDNAEntity;
import crmdna.counter.ShardEntity;
import crmdna.group.GroupEntity;
import crmdna.helpandsupport.ConfigHelpEntity;
import crmdna.interaction.InteractionEntity;
import crmdna.list.ListEntity;
import crmdna.list.ListShardEntity;
import crmdna.member.MemberEntity;
import crmdna.participant.ParticipantEntity;
import crmdna.payment.TokenEntity;
import crmdna.practice.PracticeEntity;
import crmdna.program.ProgramEntity;
import crmdna.programtype.ProgramTypeEntity;
import crmdna.registration.RegistrationEntity;
import crmdna.registration.TransactionEntity;
import crmdna.sequence.SequenceEntity;
import crmdna.teacher.TeacherEntity;
import crmdna.user.UserEntity;
import crmdna.useractivity.UserActivityEntity;
import crmdna.venue.VenueEntity;

public class OfyService {
	static {
		factory().register(ClientEntity.class);
		factory().register(CrmDnaUserEntity.class);
		factory().register(GroupEntity.class);
		factory().register(MemberEntity.class);
		factory().register(ProgramEntity.class);
		factory().register(ProgramTypeEntity.class);
		factory().register(VenueEntity.class);
		factory().register(UserEntity.class);
		factory().register(CustomFieldsEntity.class);
		factory().register(SequenceEntity.class);
		factory().register(UserActivityEntity.class);
		factory().register(InteractionEntity.class);
		factory().register(PracticeEntity.class);
		factory().register(TeacherEntity.class);
		factory().register(DummyTestEntity.class);
		factory().register(ParticipantEntity.class);
		factory().register(ShardEntity.class);
		factory().register(CheckInEntity.class);
		factory().register(IshaConfigEntity.class);
		factory().register(RegistrationEntity.class);
		factory().register(TokenEntity.class);
		factory().register(TransactionEntity.class);
		factory().register(ListEntity.class);
		factory().register(ListShardEntity.class);
		factory().register(ConfigCRMDNAEntity.class);
		factory().register(ConfigHelpEntity.class);
	}

	public static Objectify ofy(String client) {
		NamespaceManager.set(client);
		return ObjectifyService.ofy();
	}

	public static Objectify ofyCrmDna() {
		NamespaceManager.set(Constants.NAMESPACE_CRMDNA);
		return ObjectifyService.ofy();
	}

	public static ObjectifyFactory factory() {
		return ObjectifyService.factory();
	}
}